package com.markedquilt.homepage.controller;

import com.alibaba.fastjson.JSON;
import com.markedquilt.homepage.CourseInfo;
import com.markedquilt.homepage.CourseInfosRequest;
import com.markedquilt.homepage.service.ICourseService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ZhangKe
 * @Description 课程对外服务接口
 * @date 2020/12/27 16:10.
 */
@RestController
public class HomePageController {

    @Autowired
    private ICourseService courseService;

    @GetMapping("/get/course")
    public CourseInfo getCourseInfo(Long id){
//        log.info("[homepage-course] : get course -> {}",id);
        return courseService.getCourseInfo(id);
    }

    @PostMapping("/get/courses")
    public List<CourseInfo> getCourseInfos(@RequestBody CourseInfosRequest request){
//        log.info("[homepage-course] : get courses -> {}", JSON.toJSONString(request));
        return courseService.getCourseInfos(request);
    }
}
